package com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Statistics.StudyTime;

import android.os.Bundle;

import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Statistics.StudyTime.Adapter.rvStudyTimeAdapter;
import com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Statistics.StudyTime.ItemBean.StudyTime;

import com.example.tnot.R;
import com.example.tnot.Teacher.BaseFragment.BaseBackFragment;

import java.util.ArrayList;
import java.util.List;

public class StudyTimeFragment extends BaseBackFragment {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    private String mParam1;
    private String mParam2;
    private List<StudyTime> StudyTime;
    View view;
    ImageView back;
    RecyclerView rv_studyTime;


    public StudyTimeFragment() {
    }

    public static StudyTimeFragment newInstance(String param1, String param2) {
        StudyTimeFragment fragment = new StudyTimeFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.course_study_time_fragment, container, false);
        StudyTime = new ArrayList<>();
        InitData();
        rv_studyTime = view.findViewById(R.id.rv_studyTime);
        rv_studyTime.setAdapter(new rvStudyTimeAdapter(StudyTime));
        rv_studyTime.setLayoutManager(new LinearLayoutManager(getActivity()));

        back = view.findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NavController navController = Navigation.findNavController(v);
                navController.navigateUp();
            }
        });
        return view;
    }

    private void InitData() {
        //头像 姓名 学习时长统计图片
        StudyTime.add(new StudyTime(R.drawable.example_face,"qq毛",R.drawable.study_duration_chart));
        StudyTime.add(new StudyTime(R.drawable.example_face,"叶其浩",R.drawable.study_duration_chart));
        StudyTime.add(new StudyTime(R.drawable.example_face,"王怡心",R.drawable.study_duration_chart));
        StudyTime.add(new StudyTime(R.drawable.example_face,"赵京",R.drawable.study_duration_chart));
    }
}